package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划接口")
public class NursingPlanController extends BaseController{

    @Autowired
    private NursingPlanService nursingPlanService;

    @GetMapping
    public ResponseResult<List<NursingPlanVo>> getAll(){
        List<NursingPlanVo> nursingPlanAll = nursingPlanService.getAll();
        return success(nursingPlanAll);
    }

    @PostMapping
    @ApiOperation("新增护理计划")
    public ResponseResult add(@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.add(nursingPlanDto);
        return success();
    }

    @GetMapping("/search")
    @ApiOperation("分页查询护理计划")
    public ResponseResult<PageResponse<List<NursingPlanVo>>> getByPage(String name,Integer pageNum,Integer pageSize,Integer status){
        PageResponse<NursingPlanVo> pageResponse= nursingPlanService.getByPage(name,pageNum,pageSize,status);
        return success(pageResponse);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult<NursingPlanVo> getById(@PathVariable Long id){
        NursingPlanVo byPage = nursingPlanService.getById(id);
        return success(byPage);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改护理计划")
    public ResponseResult update(@RequestBody NursingPlanVo nursingPlanVo,@PathVariable Integer id){
        nursingPlanService.updatePlan(nursingPlanVo,id);
        return success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除护理计划")
    public ResponseResult deletePlan(@PathVariable Long id){
        nursingPlanService.deletePlan(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用护理计划")
    public ResponseResult updateStatus(@PathVariable Long id,@PathVariable Integer status){
        nursingPlanService.updateStatus(id,status);
        return success();
    }

}



















